package org.linlinjava.litemall.db.util;

import com.sun.org.apache.regexp.internal.RE;
import org.linlinjava.litemall.db.domain.LitemallUser;
import org.linlinjava.litemall.db.service.LitemallUserService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

public class RegistNumUtil {
    @Autowired
    private LitemallUserService userService;
    private static Integer regNum =0;
    /**
     * 一直获取注册数，直到注册数为0
     */
    public Integer getRegistNum(LitemallUser user){
        try{
            List<LitemallUser> lmUser = userService.findByParentId(1);
            System.out.println("长度："+lmUser.size());
            for (int j =0;j<lmUser.size();j++){
                if(lmUser.get(j).getRegistnum()>0){
                    regNum +=getRegistNum(lmUser.get(j))+1;
                }else{
                    return 1;
                }
            }
            return regNum;
        }catch (Exception e){
            System.out.println("暂无数据");
        }finally {
            return 0;
        }

    }
}
